#!/usr/bin/perl
# dumpmain.pl
use warnings;
use strict;

foreach my $name (sort keys %{*::}) {
   next if $name eq 'main';
   print "Symbol '$name' => \n";
 
# extract the glob reference
my $globref = ${*::} {$name};

# define local package variables through alias
local *entry = *{$globref};
# make sure we can access them in 'strict' mode
our ($entry, @entry, %entry);

# extract scalar, array, and hash via alias
print "\tScalar: $entry \n" if defined $entry;
print "\tArray : [@entry] \n" if @entry;
print "\tHash  : {", join(" ", {%entry}), "} \n" if %entry;

# check for subroutine and handle via glob
print "\tSub '$name' defined \n" if *entry{CODE};
   print "\tHandle '$name' (", fileno(*entry), ") defined \n"
   if *entry{IO};
}